package au.com.handsunited.service;

import java.util.List;

import au.com.handsunited.model.BaseEntity;
import au.com.handsunited.model.Group;
import au.com.handsunited.model.Organisation;
import au.com.handsunited.model.Project;
import au.com.handsunited.model.User;
import au.com.handsunited.model.message.Message;
import au.com.handsunited.model.relationship.Relationship;

/**
 * @author Arun Chandrasekhar
 *
 */
public interface EntityService {

	/**
	 * Creates a new entity for the given <code>owner</code>. An OWNER
	 * relationship is created between <code>newEntity</code> and
	 * <code>owner</code> in <code>newEntity</code> and an UNKNOWN
	 * relationship is created between <code>newEntity</code> and
	 * <code>owner</code> in <code>owner</code>
	 *
	 * @param newEntity
	 * @param owner
	 * @return
	 */
	BaseEntity createEntity(BaseEntity newEntity, BaseEntity owner);

	BaseEntity createEntity(BaseEntity newEntity, BaseEntity owner, BaseEntity creator);

	/**
	 * Allows the owner of a relationship to update the owned entity.
	 *
	 * @param entity
	 * @param owner
	 * @return
	 */
	BaseEntity updateEntity(BaseEntity entity, BaseEntity updatingEntity);

/*
	BaseEntity addGroupToGroupNetwork (BaseEntity entity, String groupId);
	BaseEntity addGroupToGroupNetwork (BaseEntity entity, Group group);
	BaseEntity addGroupsToGroupNetwork (BaseEntity entity, List<String> groupIds);
	BaseEntity removeGroupFromGroupNetwork (BaseEntity entity, String groupId);
	BaseEntity removeGroupFromGroupNetwork (BaseEntity entity, Group group);

	BaseEntity addOrganisationToOrganisationNetwork(BaseEntity entity, String organisationId);
	BaseEntity addOrganisationToOrganisationNetwork(BaseEntity entity, Organisation organisation);
	BaseEntity addOrganisationsToOrganisationNetwork(BaseEntity entity, List<String> organisationIds);
	BaseEntity removeOrganisationFromOrganisationNetwork(BaseEntity entity, String organisationId);
	BaseEntity removeOrganisationFromOrganisationNetwork(BaseEntity entity, Organisation organisation);

	BaseEntity addProjectToProjectNetwork(BaseEntity entity, String projectId);
	BaseEntity addProjectToProjectNetwork(BaseEntity entity, Project project);
	BaseEntity addProjectsToProjectNetwork(BaseEntity entity, List<String> projectIds);
	BaseEntity removeProjectFromProjectNetwork(BaseEntity entity, String projectId);
	BaseEntity removeProjectFromProjectNetwork(BaseEntity entity, Project project);

	BaseEntity addUserToUserNetwork (BaseEntity entity, String userId);
	BaseEntity addUserToUserNetwork (BaseEntity entity, User user);
	BaseEntity addUsersToUserNetwork(BaseEntity entity, List<String> userIds);
	BaseEntity removeUserFromUserNetwork (BaseEntity entity, String userId);
	BaseEntity removeUserFromUserNetwork (BaseEntity entity, User user);
*/


	BaseEntity postMessage(BaseEntity recipient, Message message);


	/**
	 * Allows the owner of the <code>BaseEntity</code> to delete the owned
	 * <code>BaseEntity</code>
	 *
	 * @param entity
	 * @param owner
	 */
	void deleteEntity(BaseEntity entity, BaseEntity owner);

	BaseEntity getEntity(String id);

	BaseEntity getEntity(Long id);

	List<Group> getGroupsInNetworkFor(BaseEntity entity, int firstResult, int maxResults);

	List<Relationship> getGroupRelationshipsFor(BaseEntity entity, int firstResult, int maxResults);

	List<Organisation> getOrganisationsInNetworkFor(BaseEntity entity, int firstResult, int maxResults);

	List<Relationship> getOrganisationRelationshipsFor(BaseEntity entity, int firstResult, int maxResults);

	List<Project> getProjectsInNetworkFor(BaseEntity entity, int firstResult, int maxResults);

	List<Relationship> getProjectRelationshipsFor(BaseEntity entity, int firstResult, int maxResults);

	List<User> getUsersInNetworkFor(BaseEntity entity, int firstResult, int maxResults);

	List<Relationship> getUserRelationshipsFor(BaseEntity entity, int firstResult, int maxResults);

}
